package com.example.kafkasp.Config;

import com.example.kafkasp.Service.EsChannel;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * @author CHENTAIWEN
 * @create 2022/8/24 15:07
 */
@Component
@EnableBinding(value = EsChannel.class)
public class SendService {

    @Autowired
    private EsChannel source;

    public void sendMsg(String msg) {
        source.messageDemo1Output().send(MessageBuilder.withPayload(msg).build());
        System.out.println("Demo1:"+MessageBuilder.withPayload(msg).build());
        source.messageDemo2Output().send(MessageBuilder.withPayload(msg).build());
        System.out.println("Demo2:"+MessageBuilder.withPayload(msg).build());
    }
}
